<?php
Yii::import('zii.widgets.CPortlet');

class CategoryPanel extends CPortlet
{
	public function init()
	{
		$this->title='UserPanel';
		parent::init();
	}
	
	protected function renderContent()
	{
	  echo '<pre>';
	  $allMaps = Map::model()->findAll();
	  $mapInfo = array();

	  foreach ($allMaps  as $map){
	      $mapInfo[$map->code] = array('map_name'=>$map->map_name, 'count'=>0, 't'=>0, 'f'=>0);
	  }
	  
	  $todayCount = Equation::model()->getTodayQuestionTypeDetail();
	  
	  foreach ($todayCount as $count){
	      if ($count['tof']==1){
	          //right count
	          $mapInfo[$count['map_type_code']]['t'] = $count['count_time'];
	      }else{
	          //wrong count
	          $mapInfo[$count['map_type_code']]['f'] = $count['count_time'];
	      }
	  }
	  //calculate total num
	  foreach ($mapInfo as $k=>&$roundMap){
	      $roundMap['count'] = $roundMap['f']+ $roundMap['t'];
	  }
	  
		$this->render('categoryPanel',array(
		    'mapsInfo' =>$mapInfo,
		));
	}
}